<?php
	include_once 'isLogin.php';
	$add_success = null;
	$table_name = "companies_detail_title";
	if ($_GET['level']!=''&&$_GET['level']!=null) {
	     $level = $_GET['level'];
	     $upid = $_GET['upid'];
	   
	}

	if($_POST['submit']){
		
		//插入数据库
		$data = array('title'=>$_POST['title'],'id_marking'=>$_POST['marking'],'import'=>$_POST['import'],'sort'=>$_POST['sort']);
		if($_GET['id']!=false){
			$commonc->update($table_name,$data,"id='".$_GET['id']."'");
			$href = $_basename.'?id='.$_GET['id'];
			$add_success = 2;
		}else{
		   
			$commonc->insert($table_name,$data);
			$href='company_add.php';
			$id = $commonc->insert_id();
			$data = array('sort'=>$id);
			$commonc->update($table_name, $data, "id='".$id."'");
		    $add_success = 1;
		}
		//echo $commonc->submitAlert('成功',$href);
	}
	
	//获得数据
	if($_GET['id']!=false){
		$row=$commonc->getInfo($table_name,$_GET['id']);
		$smarty->assign('row',$row);
		$smarty->assign('area',$area);
	}
	$smarty->assign('add_success',$add_success);
	$smarty->assign('level',$level);
	$smarty->assign('upid',$upid);
	$smarty->display($_filename.".html");
	
?>